import { zeroAddress } from 'viem'
import { beforeEach, describe, expect, test } from 'vitest'
import { ACTION_CONSTANTS } from '../constants/actions'
import { PoolKey } from '../types'
import { ActionsPlanner } from './ActionsPlanner'

describe('ActionsPlanner', () => {
  let actionsPlanner: ActionsPlanner
  const poolKey: PoolKey<'CL'> = {
    currency0: '0x5991A2dF15A8F6A256D3Ec51E99254Cd3fb576A9',
    currency1: '0xc7183455a4C133Ae270771860664b6B7ec320bB1',
    hooks: '0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f',
    poolManager: '0xF62849F9A0B5Bf2913b396098F7c7019b51A820a',
    fee: 3000,
    parameters: {
      tickSpacing: 3000,
    },
  }
  const takeRecipient = zeroAddress
  beforeEach(() => {
    actionsPlanner = new ActionsPlanner()
  })

  test('finalizeModifyLiquidityWithTake', () => {
    expect(actionsPlanner.finalizeModifyLiquidityWithTake(poolKey, takeRecipient)).toBe(
      '0x0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000020e0e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000600000000000000000000000005991a2df15a8f6a256d3ec51e99254cd3fb576a9000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c7183455a4c133ae270771860664b6b7ec320bb100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
    )
  })

  test('finalizeModifyLiquidityWithClose', () => {
    expect(actionsPlanner.finalizeModifyLiquidityWithClose(poolKey)).toBe(
      '0x000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000002121200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000200000000000000000000000005991a2df15a8f6a256d3ec51e99254cd3fb576a90000000000000000000000000000000000000000000000000000000000000020000000000000000000000000c7183455a4c133ae270771860664b6b7ec320bb1'
    )
  })

  test('finalizeModifyLiquidityWithSettlePair', () => {
    expect(actionsPlanner.finalizeModifyLiquidityWithSettlePair(poolKey, takeRecipient)).toBe(
      '0x0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000010d000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000400000000000000000000000005991a2df15a8f6a256d3ec51e99254cd3fb576a9000000000000000000000000c7183455a4c133ae270771860664b6b7ec320bb1'
    )
  })

  test('finalizeModifyLiquidityWithTakePair', () => {
    expect(actionsPlanner.finalizeModifyLiquidityWithTakePair(poolKey, takeRecipient)).toBe(
      '0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000600000000000000000000000005991a2df15a8f6a256d3ec51e99254cd3fb576a9000000000000000000000000c7183455a4c133ae270771860664b6b7ec320bb10000000000000000000000000000000000000000000000000000000000000000'
    )
  })

  test('finalizeSwap#is_MSG_SENDER', () => {
    expect(actionsPlanner.finalizeSwap(poolKey.currency0, poolKey.currency1, ACTION_CONSTANTS.MSG_SENDER)).toBe(
      '0x0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000020c0f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000400000000000000000000000005991a2df15a8f6a256d3ec51e99254cd3fb576a9ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000c7183455a4c133ae270771860664b6b7ec320bb10000000000000000000000000000000000000000000000000000000000000000'
    )
  })
  test('finalizeSwap#not_MSG_SENDER', () => {
    expect(actionsPlanner.finalizeSwap(poolKey.currency0, poolKey.currency1, takeRecipient)).toBe(
      '0x0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000020b0e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000600000000000000000000000005991a2df15a8f6a256d3ec51e99254cd3fb576a9000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000060000000000000000000000000c7183455a4c133ae270771860664b6b7ec320bb100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
    )
  })
})
